<?php
/**
 * Created by PhpStorm.
 * User: dev
 * Date: 23/9/14
 * Time: 12:56 PM
 */
class Admin_Settings_Local_Controller extends Admin_Controller {

    public $restful = true;

    public function __construct()
    {
        parent::__construct();
        //--Your Code --//
        $this->theme->set_theme("admin") ;
        $this->theme->set_layout("default") ;


    }

    public function get_index(){
    	if (Auth::guest()) return Redirect::to('admin/login');
    	 
    	if (!Auth::check())
    	{
    		return Redirect::to('admin/login');
    	}else{
        $data['lang'] = $this->lang;
        $data['title'] = Settings::get($this->lang, 'site_title');
        $this->theme->title("Application Settings");

        //-CONFIG--//
        $data['timezones'] = Config::get('local.timezones');
        $data['charsets'] = Config::get('local.charsets');
        $data['currency'] = Config::get('local.mb_currencies');

        return $this->theme->render('admin::settings.local',$data);
    	}
    }

    public function post_index()
    {
        if (Input::get('btnSave') == 'save') {

            Settings::saveSetting('timezone', trim(Input::get('timezone')));
            Settings::saveSetting('charecter_set', trim(Input::get('charecter_set')));
            Settings::saveSetting('short_date_format', trim(Input::get('short_date_format')));

            Settings::saveSetting('long_date_format', trim(Input::get('long_date_format')));
            Settings::saveSetting('currecy_symbol', trim(Input::get('currecy_symbol')));
            Settings::saveSetting('currency_decimal', trim(Input::get('currency_decimal')));

            Settings::saveSetting('default_location', trim(Input::get('default_location')));

        }
        return Redirect::back()->with('message','Settings Updated...');
    }
}
